/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.cei.jpah2database;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Francisco
 */
@Entity
@Table(name = "tbl_personas")
@NamedQueries({
    @NamedQuery(name = "Persona.buscarPorNombre",
    query = "SELECT p FROM Persona p WHERE p.nombre LIKE :nombre"),
    @NamedQuery(name = "Persona.buscarPorId",
    query = "SELECT p FROM Persona p WHERE p.id = :idPersona")})
public class Persona extends Contacto implements Serializable {

    private List<Contacto> contactos;

    @OneToMany
    public List<Contacto> getContactos() {
        return contactos;
    }

    public void setContactos(List<Contacto> contactos) {
        this.contactos = contactos;
    }

    @Transient
    public void getEdad() {
    }

    @Override
    public String toString() {
        return super.getId() + " - " + super.getNombre() + " - " + super.getApellido();
    }
}
